package com.example.luke.shengdangxiaoattendance.Common;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.Application;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.widget.Toast;

import com.example.luke.shengdangxiaoattendance.MainActivity;
import com.example.luke.shengdangxiaoattendance.Model.Setting;
import com.example.luke.shengdangxiaoattendance.Util.GlobalFunction;
import com.example.luke.shengdangxiaoattendance.Handler.UnCeHandler;
import com.tencent.bugly.Bugly;
import com.tencent.bugly.crashreport.CrashReport;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by luke on 24/08/2017.
 */

public class MainApp extends Application {
    ArrayList<Activity> list = new ArrayList<Activity>();

    @Override
    public void onCreate() {
        super.onCreate();
        Bugly.init(getApplicationContext(), "ede4ef270e", false);
      //  Beta.autoCheckUpgrade=true;

        CrashReport.initCrashReport(getApplicationContext());

      //  Thread.setDefaultUncaughtExceptionHandler(new UnCeHandler(this)); // 程序崩溃时触发线程  以下用来捕获程序崩溃异常
        GlobalFunction.context=getApplicationContext();

    //   Intent intent=new Intent(this,CheckExitService.class);
  //      getApplicationContext().startService(intent);
       // getApplicationContext().bindService(intent)

//getApplicationContext().bindService(intent,connection(),0);


        if (Setting.getInstallDay(this)==null)
            Setting.saveInstallDay(this);

    }



    /**
     * 关闭Activity列表中的所有Activity*/
    public void finishActivity(){
        for (Activity activity : list) {
            if (null != activity) {
                activity.finish();
            }
        }
        //杀死该应用进程
        android.os.Process.killProcess(android.os.Process.myPid());

    }




}


